const App = {
  mixins: [Query], //配置文件，路径/utils/mixins.js

  data() {
    return {
      treeData: [],
      village: [],
      Establishment_Date: '',
      form: {
        disbandDate: ''            // 解散日期
      },
      shuju: [
        {
          Captain_Number_Original: "",
          Work_Team_SerialNumber: "",
          Operation_Datetime_Original: "",
          Establishment_Date_Original: "",
          End_Date: "",
          Create_Datetime_Original: "",
          Village_Number_Original: "",
          Row_Status_Original: "",
          Work_Team_Name: "Test3333",
          Work_Team_SerialNumber_Original: "",
          Captain_Number: "",
          Mobile_Original: "",
          End_Date_Original: "",
          Operation_ID: "",
          Create_Datetime: "",
          Work_Team_Name_Original: "",
          Mobile: "",
          Operation_Datetime: "",
          Operation_ID_Original: "",
          Village_Number: "",
          Introduction_Original: "",
          Creater_SerialNumber_Original: " ",
          Introduction: "",
          Row_Status: "",
          Establishment_Date: ""
        }
      ],
      page: {
        value1: "",
        //value2:'',
        PageNumber: 1, //页码
        RowAmount: 10,
        Condition: window.btoa(unescape(encodeURIComponent("%%,%%"))),
        ExtensionCondition: window.btoa(unescape(encodeURIComponent(" and  work_teams.Village_Number in (" + getCookie('village') + ")"))),
        //Condition:"",
      },
      selectedRow: null, // 当前选中的行数据
      dialogVisible: false // 控制弹窗的显示状态
    };
  },
  mounted() { },
  methods: {
    xinwenjilu(row) {
      window.location.href = './news.html?nodeKey=' + row.Work_Team_SerialNumber
    },
    showsDialog(row) {
      console.log('点击了解散按钮，dialogVisible 设置为 true');
      this.selectedRow = row;
      console.log('28', this.selectedRow);

      this.dialogVisible = true;
    },
    confirmDissolve() {
      // 这里可以添加解散工作队的具体逻辑，例如发送请求到后端
      console.log('准备解散工作队:', this.selectedRow);
      this.dialogVisible = false; // 关闭弹窗
      // 可以在这里添加刷新表格或其他业务逻辑
    },
    confirmHandle() {

      console.log('39', this.selectedRow.Work_Team_SerialNumber);
      let _this = this;
      // 打印解散日期到控制台
      console.log('解散日期:', this.form.disbandDate);
      $.ajax({
        headers: {
          "content-type": "application/x-www-form-urlencoded",
        },
        url: `${mh}/generalBusiness/generalQueryByTableNameWithOriginal`,
        type: "POST",
        data: {
          Data: "work_teams",
          Condition: "Work_Team_SerialNumber = '" + this.selectedRow.Work_Team_SerialNumber + "'",
        },
        success: function (res) {
          console.log('成功', res);
          this.shuju = res;
          console.log('this.shuju', this.shuju);
          this.shuju[0].End_Date = _this.form.disbandDate;
          let b = {
            Modify: {
              work_teams: this.shuju // 把选中的项放入 `work_teams` 数组中
            }
          };
          console.log('118', b);
          $.ajax({
            headers: {
              "content-type": "application/x-www-form-urlencoded",
            },
            url: `${mh}/generalBusiness/generalSave`,
            method: "post",
            data: {
              Data: JSON.stringify(b),
            },

            success: (res) => {
              ElMessage.success({ message: '提交成功！', duration: 1400 })
              console.log('postgetList 存在吗？', typeof this.postgetList === 'function');
              // this 仍然是 Vue 实例
              _this.postgetList(_this.page);
            },
            error: (err) => {
              ElMessage.error({ message: '提交失败！', duration: 1500 })
              console.log('提交失败', err)
            },
          });

        },
        dataType: "json",
      });





      // 关闭弹窗
      this.dialogVisible = false;


      // 可以在这里添加其他业务逻辑，例如发送请求到后端
    },
    handleIntroduce(row) {
      window.location.href = "./addIntroduce.html?action=Modify&nodeKey=" + row.Work_Team_SerialNumber;
    },
    workteamAdd() {
      window.location.href = "./add.html?action=Add";
    },
    check() {
      //this.page.Condition = window.btoa(unescape(encodeURIComponent(this.page.value1 + ",%"+this.page.value2+"%")));
      this.page.Condition = window.btoa(
        unescape(encodeURIComponent("%" + this.page.value1 + "%" + ",%%"))
      );
      this.postgetList(this.page);
    },
    //树的点击筛选事件
    handleNodeClick(data, node) {
      this.page.Condition = window.btoa(
        unescape(
          encodeURIComponent(
            "%" + this.page.value1 + "%,%" + data.ProvinceNumber + "%"
          )
        )
      );
      this.postgetList(this.page);
    },
    MemberAdd(row) {
      let str = row["Village_Number"];

      let { primary_key } = JSON.parse(
        document.getElementById("table").getAttribute("data-options")
      );
      window.location.href =
        "./memberAddNew.html?action=Modify&Village_Number=" +
        str +
        "&nodeKey=" +
        row[primary_key];
    },
    Treedata() {
      const _this = this;
      //   $.ajax({
      //     headers: requestHeaders(),
      //     url: `${mh}/clientOperation/getDistrictTree`,
      //     type: "GET",
      //     data: {
      //       DistrictCode: "232723",
      //     },
      //     success: (data) => {
      //       this.treeData = data; // 直接使用 this
      //     },
      //     complete: (XMLHttpRequest) => {
      //       requestPretreatment(XMLHttpRequest);
      //     },
      //     dataType: "json",
      //   });


      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/permissionsTree/getDistrictTreeByPermissions`,
        type: "GET",
        data: {
          DistrictCode: getCookie('village'),
        },
        success: (data) => {
          this.treeData = data;
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
    },

    xinwen(row) {
      window.location.href = "../../news_videos_files/news/add.html?action=Add&Policy_SerialNumber=" + row.Work_Team_SerialNumber + "&News_Category_SerialNumber=NC0000000000073";
    }
  },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
